<template>
  <div class="body">
    <div class="hb-earning-con">
      <div class="part-1">
        <router-link :to="{name:'use_rules'}">
          <div class="use-gz">使用规则</div>
        </router-link>
      </div>
      <div class="part-round">
        <p class="text1">可用购物红包</p>
        <p class="price">￥{{userScore |amountMin100(2)}}</p>
      </div>
      <div class="part-3">
        <p class="tixian">购物红包明细</p>
        <div class="earnings-con" v-infinite-scroll="loadMore" infinite-scroll-disabled="busy" infinite-scroll-distance="4">
          <ul class="list-ul">
            <li class="list-li" v-for="item in shouyi_data" :key="item.id">
              <div class="top">
                <span class="left"  v-if="item.orderType==19">打赏红包</span>
                <span class="left"  v-else>{{jsonwap[item.profitType]}}</span>
                <span class="right"><span v-if="item.profitType==-3">-</span><span v-else>+</span>{{item.userProfit | amountMin100(2)}}</span>
              </div>
              <div class="bottom">
                <span class="left">余额：{{item.userBalance | amountMin100(2)}}</span>
                <span class="right">{{item.ctime |formatDateTIME()}}</span>
              </div>
            </li>
          </ul>
           <loadingtmp :busy="busy" :datalength="shouyi_data.length" :loadall="loadall"></loadingtmp>
        </div>
      </div>
    </div>
    <!-- <div class="backTo" onclick="javascript:history.back(-1);">返回</div> -->
    <business_footer :pageName="pageName"></business_footer>
  </div>
</template>
<style scoped>
  @import "../../../assets/personal/css/hb_earning.css";
  .earnings-con{
    overflow: scroll;
    height: 200px;
  }
</style>
<script>
  import business_footer from "@/components/footer"
  import loadingtmp from '@/components/load/loading'
  export default {
    components: {
      business_footer,
      loadingtmp
    },
    data(){
      return{
        pageName :"personalmine",
        userScore:'',
        shouyi_data:[],
        page:1,
        pageSize:6,
        busy:false,
        loadall: false,
        jsonwap:{
          "1":'直推红包',"2":'间推红包',"3":'平台红包',"4":'平台红包',"19":"抢红包","-3":"消费支出","5":"即时红包","6":"微传媒奖励红包"
        }
      }
    },
    methods:{
       list(flag){
        this.$http.get(this.APIURL_PREFIX+"/api/wap/accounts/scoreProfit?page="+this.page+"&rows="+this.pageSize).then((response) => {
          if(flag){
            this.shouyi_data = this.shouyi_data.concat(response.data.data);
          }else{
            this.shouyi_data = response.data.data;
          }
          if( 0 == response.data.data.length || response.data.length<this.pageSize ){
            this.busy = true;
            this.loadall = true;
          }
          else{
            this.busy = false;
            this.page++
          }
           this.wallet();
				}).catch(function(err){
					console.log(err)
				});
       },
      loadMore(){
         this.busy = true;
         setTimeout(() => {
          this.list(this.page>1);
         }, 500);
      },
       wallet(){
        this.$http.get(this.APIURL_PREFIX+"/api/wallet?page=1&rows=1").then((response) => {
          this.userScore=response.data.data.userScore
          console.log(this.userScore)
				}).catch(function(err){
					console.log(err)
				});
       }
    }
  }
</script>
